/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2023-10-18
 * Time: 10:47
 */
public class CardFlip {
    public static void main(String[] args) {
        int totalCards = 52;
        boolean[] cards = new boolean[totalCards + 1]; // 初始化为全部正面朝上

        for (int turn = 2; turn <= totalCards; turn++) {
            for (int i = turn; i <= totalCards; i += turn) {
                cards[i] = !cards[i];
            }
        }

        int count = 0;
        StringBuilder positions = new StringBuilder();

        for (int i = 1; i <= totalCards; i++) {
            if (cards[i]) {
                count++;
                positions.append(i).append(", ");
            }
        }

        System.out.println("最后正面朝上的牌有：" + count + " 张");
        System.out.println("它们的位置号是：" + positions.toString().trim());
    }
}
